import {Component, Input, ViewChild} from '@angular/core';
import * as JsBarcode from "jsbarcode";

/**
 * Generated class for the BarcodeComponent component.
 *
 * See https://angular.io/api/core/Component for more info on Angular
 * Components.
 */
@Component({
  selector: 'barcode',
  templateUrl: 'barcode.html'
})
export class BarcodeComponent {

  @Input() value: string;
  @Input() options: any;

  @ViewChild("barcode") barcode: Element;

  constructor() {
  }

  ngOnChanges() {
    JsBarcode(this.barcode['nativeElement'], this.value,
      {
        ...{
          width: 3,
          height: 50
        }, ...this.options
      })
  }

}
